package com.wisdytech.ccdserver.action.bucket;

import com.wisdytech.ccdserver.bucket.dto.BucketTenDto;
import com.wisdytech.ccdserver.bucket.serveice.IBucketService;
import com.wisdytech.ccdserver.bucket.serveice.IBucketTaskService;
import com.wisdytech.common.bean.Filter;
import com.wisdytech.common.bean.MultiResultResponse;
import com.wisdytech.common.bean.UniqueResultResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.InputStream;
import java.util.List;

/**
 * @author SV00216491
 * @description: TODO
 * @date 2024-04-01 14:32:27
 * @version: 1.0
 */

@RestController
@RequestMapping("ccdserver/bucketAction/")
public class CcdAction {
    @Autowired
    private IBucketService bucketService;
    @Autowired
    private IBucketTaskService bucketTaskService;


    //图片同步下载
    @RequestMapping("listBuckets")
    public UniqueResultResponse listBucket(Filter filter) throws Exception {
        UniqueResultResponse bucketList = bucketService.getBucketList(filter);
        return bucketList;
    }

    @RequestMapping("listBucketsTen")
    public UniqueResultResponse getBucketsTen(Filter filter) throws Exception {
        UniqueResultResponse bucketList = bucketService.getBucketListTen(filter);
        return bucketList;
    }

    @RequestMapping("downloadCcdTemplate")
    public UniqueResultResponse downloadCcdTRemplate(Filter filter) throws Exception {
        UniqueResultResponse bucketList = bucketService.downloadCcdTemplate(filter);
        return bucketList;
    }

    //进度条接口
    @RequestMapping("findTaskAndSearchProgress")
    public MultiResultResponse findTaskAndSearchProgress(Filter filter) {
        MultiResultResponse bucketList = bucketTaskService.findTaskAndSearchProgress(filter);
        return bucketList;
    }

    @RequestMapping("listBucketsByName")
    public UniqueResultResponse getBucketsByName(Filter filter) throws Exception {
        UniqueResultResponse bucketList = bucketService.getBucketsByName(filter);
        return bucketList;
    }

    @RequestMapping("listDirectorys")
    public UniqueResultResponse getDirectorys(Filter filter) throws Exception {
        UniqueResultResponse bucketList = bucketService.getDirectorys(filter);
        return bucketList;
    }

    @RequestMapping("imapgePreview")
    public UniqueResultResponse getImageUrl(Filter filter) throws Exception {
        UniqueResultResponse bucketList = bucketService.getImageUrl(filter);
        return bucketList;
    }

    @RequestMapping("imageDownload")
    public InputStream getImage(Filter filter) throws Exception {
        return bucketService.getImage(filter);
    }

    @RequestMapping("listBucketsByPage")
    public MultiResultResponse getBucketsByPage(Filter filter) throws Exception {
        MultiResultResponse bucketList = bucketService.getBucketsByPage(filter);
        return bucketList;
    }

    @RequestMapping("listBucketsByPages")
    public BucketTenDto getBucketsByPages(Filter filter) throws Exception {
        BucketTenDto bucketList = bucketService.getBucketsByPages(filter);
        return bucketList;
    }

    //手动执行
    @RequestMapping("manualOperationBucketTask")
    public UniqueResultResponse manualOperationBucketTask(Filter filter) {
        UniqueResultResponse response = bucketService.manualOperationBucketTask(filter);
        return response;
    }

    //删除任务 - 删除任务 - 页面物理删除
    @RequestMapping("deleteBucketTaskByIds")
    public UniqueResultResponse deleteBucketTaskByIds(Filter filter) {
        UniqueResultResponse response = bucketTaskService.deleteBucketTaskByIds(filter);
        return response;
    }

    //删除任务 -  不删除任务
    @RequestMapping("asyncBucketTaskByIds")
    public void asyncBucketTaskByIds() {
        bucketTaskService.asyncBucketTaskByIds();
    }

    //中止任务
    @RequestMapping("interruptBucketTaskByIds")
    public UniqueResultResponse interruptBucketTaskByIds(Filter filter) {
        UniqueResultResponse response = bucketTaskService.interruptBucketTaskByIds(filter);
        return response;
    }

}
